

#ifndef   _ZLTRANSMAN_H
#define   _ZLTRANSMAN_H

#include "zrxnames.h"
#include "zdbidar.h"
#pragma pack (push, 8)

class UcDbLongTransaction;
class UcDbDatabase;
class UcDbIdMapping;
class UcApDocument;

#define UC_LONG_TRANSACTION_MANAGER_OBJ _T("UcApLongTransactionManager")

class UcApLongTransactionReactor: public UcRxObject 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcApLongTransactionReactor);

    virtual void beginCheckOut        (UcDbLongTransaction& ,
                                       UcDbObjectIdArray& originList);
    virtual void endCheckOut          (UcDbLongTransaction& );
    virtual void beginCheckIn         (UcDbLongTransaction& );
    virtual void endCheckIn           (UcDbLongTransaction& );
    virtual void abortLongTransaction (UcDbLongTransaction& );

protected:
    Ucad::ErrorStatus veto ();  

private:
    ZSoft::UInt8 mVeto;

friend class UcApImpLongTransactionManager;
};

class UcApLongTransactionManager: public UcRxObject 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcApLongTransactionManager);

    virtual Ucad::ErrorStatus   checkOut(
                                   UcDbObjectId& transId,
                                   UcDbObjectIdArray& objList,
                                   UcDbObjectId toBlock,
                                   UcDbIdMapping& errorMap,
                                   UcDbObjectId lockBlkRef = 
                                       UcDbObjectId::kNull) = 0;

    virtual Ucad::ErrorStatus   checkIn  (
                                   UcDbObjectId transId,
                                   UcDbIdMapping& errorMap,
                                   bool keepObjs = false) = 0;

    virtual Ucad::ErrorStatus   abortLongTransaction(
                                   UcDbObjectId transId,
                                   bool keepObjs = false) = 0;

    virtual UcDbObjectId        currentLongTransactionFor(
                                   const UcApDocument* pDoc) const = 0;

    virtual void                addReactor(UcApLongTransactionReactor*) = 0;
    virtual void                removeReactor(UcApLongTransactionReactor*) = 0;

    virtual Ucad::ErrorStatus   addClassFilter (UcRxClass* ) = 0;
    virtual bool                isFiltered (UcRxClass* ) const = 0;
};

extern UcApLongTransactionManager* ucapLongTransactionManagerPtr();
#define ucapLongTransactionManager  ucapLongTransactionManagerPtr()

#pragma pack (pop)
#endif  
